#include "importnetworkdialog.h"
#include "ui_importnetworkdialog.h"

#include <httpclient.h>

ImportNetworkDialog::ImportNetworkDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ImportNetworkDialog)
{
    ui->setupUi(this);
    ui->buttonBox->setEnabled(false);
}

ImportNetworkDialog::~ImportNetworkDialog()
{
    delete ui;
}

QString ImportNetworkDialog::content() const
{
    return ui->text_content->toPlainText();
}

void ImportNetworkDialog::on_btn_request_clicked()
{
    auto resp = HttpClient::instance().get(ui->edit_url->text());
    auto json = resp.toJson();
    ui->text_content->setPlainText(json);
    if (resp.ok()) {
        ui->buttonBox->setEnabled(true);
    }
}

